// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

.btn-osu-big {
  @top: btn-osu-big;

  --active-bg: var(--hover-bg);
  --active-colour: var(--hover-colour);
  --bg: hsl(var(--hsl-h2));
  --colour: hsl(var(--hsl-c1));
  --disabled-bg: hsl(var(--hsl-b3));
  --disabled-colour: hsl(var(--hsl-f1));
  --disabled-opacity: 1;
  --focus-bg: var(--hover-bg);
  --focus-colour: var(--hover-colour);
  --hover-bg: hsl(var(--hsl-h1));
  --hover-colour: hsl(var(--hsl-c1));
  .reset-input();
  .link-plain();
  .default-border-radius();
  border: none;

  display: inline-block;

  background: var(--bg);
  transition: background-color 120ms;

  padding: 5px;
  color: var(--colour);
  font-size: @font-size--normal;
  font-weight: 600;
  overflow: hidden;
  cursor: pointer;
  text-transform: none;
  white-space: nowrap;
  // Uniform behaviour between a/button/span.
  // The default is baseline but button's baseline is quite a bit
  // different compared to other elements.
  vertical-align: middle;

  &:focus {
    color: var(--focus-colour);
    background: var(--focus-bg);
  }

  &:hover {
    color: var(--hover-colour);
    background: var(--hover-bg);
  }

  &:active {
    color: var(--active-colour);
    background: var(--active-bg);
  }

  &[disabled],
  &--disabled {
    cursor: default;
    background: var(--disabled-bg);
    color: var(--disabled-colour);
    opacity: var(--disabled-opacity);

    .link-hover({
      background: var(--disabled-bg);
      color: var(--disabled-colour);
    });
  }

  &--account-edit {
    min-width: @avatar-size--base;
    padding: 7px 10px;
    text-align: left;
    overflow: hidden;
    position: relative;
  }

  &--account-edit-small {
    min-width: 70px;
  }

  &--artist-track-search {
    --disabled-bg: hsl(var(--hsl-b2));
  }

  &--beatmapset-header {
    min-width: 120px;
    height: 45px;
    margin: 0 5px 5px 0;
  }

  &--beatmapset-header-square {
    width: 45px;
    height: 45px;
    margin: 0 5px 5px 0;
  }

  &--comment-editor {
    min-width: 80px;
    border-radius: 10000px;
    padding: 5px;
    --disabled-bg: hsl(var(--hsl-b5));
    --disabled-colour: hsl(var(--hsl-f1));
  }

  &--chat-send {
    min-width: 80px;
    border-radius: 10000px;
    padding: 10px;
    align-self: flex-end;

    --bg: hsl(var(--hsl-h2));
    --hover-bg: hsl(var(--hsl-h1));

    @media @desktop {
      min-width: 130px;
      padding: 10px 20px;
    }
  }

  &--contest-download {
    width: 300px;
    height: 45px;
    margin: 0 5px 5px 0;
    &:hover {
      background-position: calc(50% - (20px - 2px)) 50%;
    }
  }

  &--contest-entries-toolbar {
    font-size: inherit;
    line-height: normal;
    text-transform: uppercase;
    padding: 5px 10px;
    margin: 0 10px;
    transition: none;
    --bg: transparent;
    --colour: hsl(var(--hsl-f1));
    --hover-bg: hsl(var(--hsl-b3));
  }

  &--danger {
    --bg: hsl(var(--hsl-red-3));
    --hover-bg: hsl(var(--hsl-red-2));
  }

  &--download {
    --bg:
      var(--cookie) right 15% center no-repeat,
      linear-gradient(var(--overlay-colour), var(--overlay-colour)) padding-box,
      linear-gradient(
          to bottom,
          var(--overlay-colour),
          hsla(var(--bg-colour), 0.8),
          hsla(var(--bg-colour), 0.9)
        )
        border-box;

    --hover-bg:
      var(--cookie) right 15% center no-repeat,
      linear-gradient(hsla(var(--bg-colour), 0.5), hsla(var(--bg-colour), 0.5))
        padding-box,
      linear-gradient(
          to bottom,
          hsla(var(--bg-colour), 0.5),
          hsla(var(--bg-colour), 0.8),
          hsla(var(--bg-colour), 0.9)
        )
        border-box;

    --bg-colour: var(--hsl-pink-1);
    --cookie: url("~@images/backgrounds/cookie_v3.svg");
    --overlay-colour: rgba(0, 0, 0, 0.75);

    .default-text-shadow();
    display: flex;
    flex-direction: column;
    border-radius: 20px;
    border: 2px solid transparent;
    padding: $border-radius;
    width: 100%;
  }

  &--download-landing {
    .default-box-shadow();
    .default-text-shadow();
    font-size: @font-size--title-small;
    padding: 10px 5px;
  }

  &--download-stable {
    --bg-colour: var(--hsl-orange-1);
    --cookie: url("~@images/backgrounds/cookie_v2.svg");
    --overlay-colour: hsla(var(--hsl-b5), 0.75);
  }

  &--fileupload {
    overflow: hidden;
    position: relative;
  }

  &--mega {
    width: 100%;
    height: 50px;
    font-size: 18px;
    .center-content();
  }

  &--forum-button {
    padding: 8px 15px;

    border-radius: 10000px;
    .default-text-shadow();
    font-weight: normal;
    // remove line descenders on <a>; should probably go on the block if
    // the existing doesn't magically break.
    vertical-align: middle;

    --active-bg: hsl(var(--hsl-blue-3));
    --bg: hsl(var(--hsl-blue-3));
    --hover-bg: hsl(var(--hsl-blue-2));
  }

  &--forum-cover {
    .default-text-shadow();
    padding: 8px 15px;
    border-radius: 100000px;
    font-weight: normal;
    position: relative;

    --bg: hsl(var(--hsl-orange-3));
    --colour: hsl(var(--hsl-c1));
    --disabled-bg: hsl(var(--hsl-orange-3));
    --disabled-colour: hsl(var(--hsl-c1));
    --disabled-opacity: 0.5;
    --hover-bg: hsl(var(--hsl-orange-2));
  }

  &--forum-cover-edit {
    margin: 10px 15px;
    min-width: 135px;
  }

  &--forum-primary {
    border-radius: 10000px;
    padding: 8px 20px;
    font-weight: normal;
    .default-text-shadow();

    --bg: hsl(var(--hsl-lime-3));
    --disabled-bg: hsl(var(--hsl-lime-3));
    --disabled-colour: hsl(var(--hsl-c1));
    --disabled-opacity: 0.5;
    --hover-bg: hsl(var(--hsl-lime-2));
  }

  &--forum-reply {
    margin: 0 3px;
    border-radius: 10000px;
    padding: 0 10px;
    height: @btn-circle-diameter;
    --bg: hsl(var(--hsl-l4));
    --focus-bg: hsl(var(--hsl-l4));
    --hover-bg: hsl(var(--hsl-l3));
  }

  &--forum-secondary {
    border-radius: 10000px;
    padding: 8px 20px;
    font-weight: normal;
    .default-text-shadow();

    --bg: hsl(var(--hsl-blue-3));
    --disabled-bg: hsl(var(--hsl-blue-3));
    --disabled-colour: hsl(var(--hsl-c1));
    --disabled-opacity: 0.5;
    --hover-bg: hsl(var(--hsl-blue-2));
  }

  &--full {
    width: 100%;
  }

  &--nav-popup {
    text-align: left;
    width: 120px;
    height: 35px;
    padding: 7px 10px;
  }

  &--password-reset {
    padding: 10px;
    text-align: center;
    border-radius: 10000px;
  }

  &--pink {
    --bg: hsl(var(--hsl-pink-3));
    --hover-bg: hsl(var(--hsl-pink-2));
  }

  &--quick-search-close {
    .default-text-shadow();
    border-radius: 10000px;
    padding: 10px 30px;
    font-size: @font-size--title-small-3;
    line-height: normal;
    flex: none;
    margin-left: 20px;
  }

  &--rounded {
    padding: 10px 15px;
    border-radius: 100000px;
  }

  &--rounded-small {
    border-radius: 100000px;
    padding: 4px 10px;
  }

  &--rounded-thin {
    padding: 8px 15px;
    border-radius: 100000px;
  }

  &--rounded-thin-wide {
    padding: 8px 40px;
    border-radius: 100000px;
  }

  &--store-action {
    display: block;
    width: max-content;
    max-width: 100%;
    margin: 0 auto;
    font-size: @font-size--title-small;
    padding: 10px 50px;
    border-radius: 10000px;
    line-height: normal;
    text-align: center;
  }

  &--store-cart {
    padding: 5px 15px;
    border-radius: 10000px;
    margin: 10px 0;
    width: 100%;

    @media @desktop {
      margin: 0 0 0 auto;
      width: auto;
    }
  }

  &--store-cart-delete {
    padding: 5px 10px;
    line-height: normal;
    font-size: @font-size--title-small-3;
    --bg: none;
    --disabled-bg: none;
    --hover-bg: none;
  }

  &--tournament-info {
    font-size: @font-size--title-small-3;
    padding: 10px 30px;
    border-radius: 10000px;
  }

  &--tournament-register {
    font-size: @font-size--title-small-3;
    padding: 10px 40px;
    border-radius: 10000px;
    margin-top: 10px;
  }

  &--user-page-edit {
    border-radius: 10000px;
    width: 140px;
    padding: 5px 10px;
  }

  &--warning {
    --bg: hsl(var(--hsl-orange-3));
    --hover-bg: hsl(var(--hsl-orange-2));
  }

  &--wrap-text {
    white-space: normal;
  }

  &--activated,
  &.js-activated {
    --bg: hsl(var(--hsl-h2));
    --colour: hsl(var(--hsl-c1));
    --hover-colour: hsl(var(--hsl-c1));
  }

  &.js-click-menu--active {
    --bg: var(--hover-bg);
    --colour: var(--hover-colour);
  }

  &__content {
    width: 100%;
    height: 100%;

    display: flex;
    justify-content: space-between;
    align-items: center;

    &--center {
      justify-content: center;
    }

    .@{top}--account-edit & {
      width: auto;
      margin: 0 -5px;
    }

    .@{top}--forum-reply & {
      // aligned to my system
      top: -1px;
    }

    .@{top}--nav-popup & {
      width: auto;
      margin: 0 -5px;
    }
  }

  &__icon {
    flex: none;
    margin: 0 5px;
    font-size: 150%;

    .@{top}--account-edit & {
      height: 0;
      display: flex;
      flex-direction: column;
      justify-content: center;
    }

    .@{top}--comment-editor,
    .@{top}--chat-send & {
      font-size: 120%;
    }

    .@{top}--download & {
      display: flex;
      margin: 0;
      font-size: 24px;
    }

    .@{top}--download-landing & {
      .circle(40px);
      .center-content();
      .thick-box-shadow();
      margin-left: 20px;
      font-size: 20px;
      border: 2px solid #fff;
    }

    .@{top}--nav-popup & {
      height: 0;
      display: flex;
      flex-direction: column;
      justify-content: center;
    }

    .@{top}--forum-reply & {
      margin-right: 0;
    }
  }

  &__icon-inline {
    --margin: 5px;

    &--left {
      margin-right: var(--margin);
    }

    &--right {
      margin-left: var(--margin);
    }
  }

  &__left {
    margin: 0 5px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: left;

    .@{top}--beatmap-discussion-reply-open & {
      margin-right: 20px;
    }

    .@{top}--download & {
      margin: 0; // all in the top-level padding
      gap: 10px;
    }
  }

  &__loading-spinner {
    position: absolute;
    right: 10px;
    opacity: 0;

    .@{top}[data-state="loading"] & {
      opacity: 1;
    }
  }

  &__text-top {
    &--download {
      font-size: @font-size--large;
      font-weight: 700;
    }
  }

  &__text-bottom {
    font-size: @font-size--small;

    &--download {
      font-weight: 300;
    }
  }

  &__toggle {
    margin: 0 5px;
    color: @osu-colour-d1;

    .@{top}.js-activated & {
      color: @osu-colour-c1;
      text-shadow: 0 0 10px @osu-colour-c2;
    }
  }
}
